package com.example.finalexam;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import java.util.ArrayList;

public class SeekActivity extends AppCompatActivity {
    Button buttonseek;
    EditText sword;
    TextView stranslate;
    private DBManager dbs;
    ArrayList<Word> words;
    String word;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_seek);
        buttonseek = (Button) findViewById(R.id.buttonseek);
        sword = (EditText) findViewById(R.id.sword);
        stranslate = (TextView) findViewById(R.id.stranslate);
        dbs=new DBManager(this);
        words=dbs.getWords();
    }
    public void seek(View view){
        word=sword.getText().toString();
        for(int i=0;i<words.size();i++){
            if(word.equals(words.get(i).en_meaning)){
                stranslate.setText(words.get(i).cn_meaning);
            }
        }
    }
    public void f_Click(View view){
        Intent intent=new Intent(SeekActivity.this,MainActivity.class);
        startActivity(intent);
    }
}